package com.xbongbong.pro.enums.businessrule.enums;

import com.xbongbong.paas.enums.FieldTypeEnum;
import lombok.Getter;

import java.util.Objects;

/**
 * @author 吴峰
 * @version v1.0
 * @date 2019/9/26 10:33
 * @since v1.0
 */
@Getter
public enum RuleConditionFieldEnum {

    /**
     * 适合业务规则过滤条件的字段
     */
    TEXT(FieldTypeEnum.TEXT),

    COMBO(FieldTypeEnum.COMBO),

    RADIO_GROUP(FieldTypeEnum.RADIO_GROUP),

    SERIAL_NO(FieldTypeEnum.SERIALNO),

    TEXTAREA(FieldTypeEnum.TEXTAREA),
    // TODO 暂时去掉多选的条件，因为子表单字段多行时，多选字段会有筛选问题
//    COMBO_CHECK(FieldTypeEnum.COMBO_CHECK),

//    CHECKBOX_GROUP(FieldTypeEnum.CHECKBOX_GROUP),

    NUM(FieldTypeEnum.NUM),

    DATETIME(FieldTypeEnum.DATETIME),

    ADDTIME(FieldTypeEnum.ADDTIME),

    UPDATETIME(FieldTypeEnum.UPDATETIME),

    ADDRESS(FieldTypeEnum.ADDRESS),

    USER(FieldTypeEnum.USER),

    SUB_FORM(FieldTypeEnum.SUB_FORM),

    CREATORID(FieldTypeEnum.CREATORID),

//    OWNERID(FieldTypeEnum.OWNERID),

//    USER_GROUP(FieldTypeEnum.USER_GROUP),

    DEPT(FieldTypeEnum.DEPT),
    // deptgroup 部门多选
//    DEPT_GROUP(FieldTypeEnum.DEPT_GROUP),

    LINK_DATA(FieldTypeEnum.LINK_DATA),

    LINK_BUSINESS_SINGLE(FieldTypeEnum.LINK_BUSINESS_SINGLE),

    DEPARTMENTID(FieldTypeEnum.DEPARTMENTID),

    //阶段推进器
    STAGE_THRUSTER(FieldTypeEnum.STAGE_THRUSTER),
    ;

    private FieldTypeEnum fieldTypeEnum;

    RuleConditionFieldEnum(FieldTypeEnum fieldTypeEnum) {
        this.fieldTypeEnum = fieldTypeEnum;
    }

    public static RuleConditionFieldEnum getByCode(Integer fieldType) {
        for (RuleConditionFieldEnum ruleConditionFieldEnum : values()) {
            if (Objects.equals(ruleConditionFieldEnum.getFieldTypeEnum().getType(), fieldType)) {
                return ruleConditionFieldEnum;
            }
        }
        return null;
    }
}
